package com.xique.door.bean.validation;

import com.xique.common.core.utils.StringUtils;
import com.xique.door.bean.domain.Visitor;
import org.springframework.stereotype.Component;

/**
 * @Auther: caogq
 * @Date: 2021/7/7 11:32
 * @Description:
 */
@Component
public class VisitorValidation {

    public Boolean saveVisitor(Visitor visitor){
        if (StringUtils.isEmpty(visitor.getVisitorType()) || StringUtils.isEmpty(visitor.getVisitorName()) || StringUtils.isEmpty(visitor.getPhone())){
            return false;
        }
        if ("1".equals(visitor.getVisitorType()) ||"2".equals(visitor.getVisitorType())){
            //访客类型为时间段时，必填开始时间和结束时间
            if (visitor.getStartTime() == null || visitor.getEndTime() == null){
                return false;
            }
        }
        if ("3".equals(visitor.getVisitorType()) && visitor.getEffectNumber() == null){
            return false;
        }
        return true;
    }
}
